<#import "/_admin/lib/sidbar_templet.html" as sidbarTemplet>
<!DOCTYPE html>
<html lang="zh-cn">

<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Exam</title>

<!-- Bootstrap -->
<link href="/static/assets/yeti/bootstrap.min.css" rel="stylesheet">
<link rel="stylesheet" href="/static/assets/jedate/skin/jedate.css">
<link rel="stylesheet" href="/static/css/style.css" />
<link href="/static/assets/toastr-master/toastr.css" rel="stylesheet"/>
<link href="/static/assets/bootstrap-validator/css/bootstrapValidator.min.css" rel="stylesheet">


<!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
<!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
<!--[if lt IE 9]>
      <script src="http://cdn.bootcss.com/html5shiv/3.7.2/html5shiv.min.js"></script>
      <script src="http://cdn.bootcss.com/respond.js/1.4.2/respond.min.js"></script>
    <![endif]-->
</head>

<body>

<@sidbarTemplet.header />

	<div class="container-fluid">
		<div class="col-xs-2 sidebar">
			<ul class="nav nav-sidebar">
				<@sidbarTemplet.sidbar "test-paper.html" />
			</ul>
		</div>
		<div class="col-xs-10 col-xs-offset-2 content" id="content">
			<!--content-->

			<div class="panel panel-primary">
				<div class="panel-heading">
					<h2 class="panel-title pull-left" style="line-height: 39px;">${testPaper.testpaperName}</h2>
					<div class="clearfix"></div>
				</div>
				<div class="panel-body">
					<form id="formid">
						<div class="form-group">
							<label for="exampleInputEmail1">试卷id</label> <input
								name="testpaperId" type="text" class="form-control"
								disabled="true " placeholder="试卷id"
								value="${testPaper.testpaperId}">
								 <input name="testpaperId" type="text" class="form-control" style="display:none" placeholder="login" value="${testPaper.testpaperId}">
						</div>
						<div class="form-group">
							<label for="exampleInputPassword1">试卷描述</label> <input
								name="testpaperName" type="text" class="form-control"
								placeholder="试卷描述" value="${testPaper.testpaperName}">
						</div>
						<div class="form-group">
							<label for="exampleInputPassword1">开始时间</label> <input
								name="startDate" type="text" class="form-control"
								placeholder="开始时间" id="inpstart" readonly value="${testPaper.startDate}">
						</div>
						<div class="form-group">
							<label for="exampleInputPassword1">结束时间</label> <input
								name="endDate" type="text" class="form-control"
								id="inpend" readonly value="${testPaper.endDate}">
						</div>
						<button type="submit" class="btn btn-danger"
							style="margin: 0 auto; width: 80%; height: 100%; margin-left: 10%">修改</button>
					</form>

				</div>
			</div>

		</div>
		<!--content-->
	</div>

		<!-- jQuery (necessary for Bootstrap's JavaScript plugins) -->
		<script type="text/javascript" src="/static/js/jquery-1.10.2.min.js"></script>
		<!-- Include all compiled plugins (below), or include individual files as needed -->
		<script src="/static/js/bootstrap.min.js"></script>
		<script type="text/javascript" src="/static/assets/jedate/jedate.js"></script>
		<script type="text/javascript" src="/static/assets/vue/vue.js"></script>
		<script type="text/javascript" src="/static/js/common.js"></script>
		<script src="/static/assets/toastr-master/toastr.js" type="text/javascript"></script>
		<script src="/static/assets/bootstrap-validator/js/bootstrapValidator.min.js" type="text/javascript"></script>
		
     <script type="text/javascript">
		var ajaxConfig = {
		   type: "POST",
		   dataType: "json",
		   async: false,			
		};
		function ajaxSubmit(url, data, successFn, errorFn) {
			ajaxConfig.url = url;
			if(data != null) {
				ajaxConfig.data = data;
			};
			ajaxConfig.success = function(data) {
				successFn(data);
			};
			ajaxConfig.error = function(data) {
				errorFn(data);
			};
			$.ajax(ajaxConfig);
		};
		
		/* 提示插件配置 */
		toastr.options = {
		  "closeButton": true,
		  "debug": false,
		  "progressBar": false,
		  "positionClass": "toast-top-right",
		  "onclick": null,
		  "showDuration": "300",
		  "hideDuration": "1000",
		  "timeOut": "5000",
		  "extendedTimeOut": "1000",
		  "showEasing": "swing",
		  "hideEasing": "linear",
		  "showMethod": "fadeIn",
		  "hideMethod": "fadeOut"
		};
		
		$(function(){/* 文档加载，执行一个函数*/
		     $('#formid').bootstrapValidator({
		         message: 'This value is not valid',
		         feedbackIcons: {/*input状态样式图片*/
		             valid: 'glyphicon glyphicon-ok',
		             invalid: 'glyphicon glyphicon-remove',
		             validating: 'glyphicon glyphicon-refresh'
		         },
		         fields: {/*验证：规则*/
		        	 testpaperName: {//验证input项：验证规则
		                 message: 'The username is not valid',
		                
		                 validators: {
		                     notEmpty: {//非空验证：提示消息
		                         message: '不能为空'
		                     },
		                     stringLength: {
		                         min: 1,
		                         max: 255,
		                         message: '长度必须在1到255之间'
		                     }
		                 }
		             },
		             startDate: {
		                 message: 'The nicename is not valid',
		                
		                 validators: {
		                     notEmpty: {
		                         message: '不能为空'
		                     }
		                 }
		             },
		             endDate: {
		                 message: '时间不能为空',
		                
		                 validators: {
		                     notEmpty: {
		                         message: '时间不能为空'
		                     }
		                 }
		             }

		         }
		     }).on('success.form.bv', function(e) {//点击提交之后
		         // Prevent form submission
		         e.preventDefault();
				ajaxSubmit(
					"/admin/testPaperEdit",
					$("#formid").serialize(),
					function(data) {
						if(data == true) {
							toastr.success('修改成功!', '设置');
						}
					},
					function(data) {
						toastr.error('修改失败!', '设置');
					}
				);
		         
		    });
		});
		
	    var start = {
	    	    dateCell: '#inpstart',
	    	    format: 'YYYY-MM-DD hh:mm',
	    	    minDate: '2014-06-16 23:59:59', //设定最小日期为当前日期
	    		festival:true,
	    	    maxDate: '2099-06-16 23:59:59', //最大日期
	    	   isTime: true,
	    	    choosefun: function(datas){
	    	         end.minDate = datas; //开始日选好后，重置结束日的最小日期
	    	    }
	    	};
	    	var end = {
	    	    dateCell: '#inpend',
	    	    format: 'YYYY-MM-DD hh:mm',
	    	    minDate: jeDate.now(0), //设定最小日期为当前日期
	    		festival:true,
	    	    maxDate: '2099-06-16 23:59:59', //最大日期
	    	    isTime: true,
	    	    choosefun: function(datas){
	    	         start.maxDate = datas; //将结束日的初始值设定为开始日的最大日期
	    	    },
	    		okfun:function(val){alert(val)}
	    	};
	    	jeDate(start);
	    	jeDate(end);		
 </script>
</body>

</html>